﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using FeedAntGame.Sprite;

namespace FeedAntGame.Control
{
    /// <summary>
    /// Manage Barrier in game
    /// </summary>
    class Barrier : BaseControl
    {
        
        public enum TYPE { ROCK1, ROCK2, ROCK3, ROCK4 }

        TYPE type = TYPE.ROCK1;

        /************************************************************************/
        /*                      GET/SET                                                                     */
        /************************************************************************/
        
        internal TYPE Type
        {
            get { return type; }
            set 
            {
                type = value;
                createInstance(sprite.Position);
            }
        }

        /************************************************************************/
        /*                  Constructor                                                                     */
        /************************************************************************/
        public Barrier(Game game, TYPE type, Vector2 position)
            :base(game)
        {
            this.type = type;
            createInstance(position);
        }

        protected override void createInstance(Vector2 position)
        {
            switch (type)
            {
                case TYPE.ROCK1:
                    {
                        sprite = new AutomatedSprite(
                                        ((GameFA)Game).Content.Load<Texture2D>(@"Images\rock1"), position,
                                        new Point(80, 54), 5, Point.Zero,
                                        new Point(1, 1), Vector2.Zero, null, 0, 1
                                        );
                    }

                    break;
                case TYPE.ROCK2:
                    {
                        sprite = new AutomatedSprite(
                                        ((GameFA)Game).Content.Load<Texture2D>(@"Images\rock2"), position,
                                        new Point(60, 76), 5, Point.Zero,
                                        new Point(1, 1), Vector2.Zero, null, 0, 1
                                        );
                    }

                    break;
                case TYPE.ROCK3:
                    {
                        sprite = new AutomatedSprite(
                                        ((GameFA)Game).Content.Load<Texture2D>(@"Images\rock3"), position,
                                        new Point(80, 91), 5, Point.Zero,
                                        new Point(1, 1), Vector2.Zero, null, 0, 1
                                        );
                        //sprite.Rotation = ((GameFA)game).rnd.Next() % 360;
                    }
                    break;
                case TYPE.ROCK4:
                    {
                        Random rnd = ((GameFA)Game).rnd;
                        sprite = new AutomatedSprite(
                                        ((GameFA)Game).Content.Load<Texture2D>(@"Images\rock4"), position,
                                        new Point(100, 100), 0, new Point(0,0),
                                        new Point(1, 1), Vector2.Zero, rnd.Next(50, 60), null, 0, 0.75f
                                        );
                    }
                    break;
                default:
                    break;
            }
        }
    }
}
